package com.ruoyi.web.controller.carrepairmanage;

import com.ruoyi.car.domain.CarManage;
import com.ruoyi.car.domain.CatRepair;
import com.ruoyi.car.domain.CatUpkeep;
import com.ruoyi.car.service.ICarManageService;
import com.ruoyi.car.service.ICatRepairService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.domain.MtProBuild;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 车辆管理Controller
 *
 * @author ruoyi
 * @date 2020-06-18
 */
@Controller
@RequestMapping("/ruoyi/manages")
public class CarManagesController extends BaseController
{
    private String prefix = "ruoyi/manages";
    @Autowired
    private ICarManageService carManageService;
    @Autowired
    private ICatRepairService catRepairService;
    @RequiresPermissions("ruoyi:manages:view")
    @GetMapping()
    public String manages()
    {
        return prefix + "/manages";
    }

    /**
     * 查询车辆管理
     列表
     */
    @RequiresPermissions("ruoyi:manages:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CarManage carManage)
    {
        startPage();
        List<CarManage> list = carManageService.selectCarManageList(carManage);
        return getDataTable(list);
    }

    /**
     * 查询车辆维修管理列表
     */
    @RequiresPermissions("ruoyi:manages:lists")
    @PostMapping("/lists/{cCarid}")
    @ResponseBody
    public TableDataInfo lists(@PathVariable("cCarid") String cCarid, CatRepair catRepair)
    {
        catRepair.setcCarld(cCarid);
        startPage();
        List<CatRepair> lists = catRepairService.selectCat(catRepair);
        return getDataTable(lists);
    }

    /**
     * 修改【请填写功能名称】
     */
    @GetMapping("/editM/{id}")
    public String edit(@PathVariable("id") Long cId, ModelMap mmap)
    {
        CatRepair catRepair = catRepairService.selectCatRepairById(cId);
        mmap.put("catRepair", catRepair);
        return prefix + "/editM";
    }

    /**
     * 修改保存【请填写功能名称】
     */
    @RequiresPermissions("ruoyi:manages:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PostMapping("/editM")
    @ResponseBody
    public AjaxResult editSave(CatRepair catRepair)
    {
        return toAjax(catRepairService.updateCatRepair(catRepair));
    }



    @GetMapping("/detail/{cCarid}")
    public String detail(@PathVariable("cCarid") String cCarid, ModelMap map) {
        map.put("cCarid", cCarid);
        return prefix + "/managesdetail";
    }

}
